package com.zb.Service.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.zb.Service.ContactService;
import com.zb.Service.FullCalendarService;
import com.zb.Service.SheduleService;
import com.zb.entity.Contact;
import com.zb.entity.FullCalendar;
import com.zb.entity.Shedule;
@Component("FullCalendarService")
public class FullCalendarServiceImpl implements FullCalendarService {
	@Autowired
	private SheduleService shdservice;
	@Autowired
	private ContactService conservice;
	
	public List<FullCalendar> getFullcAboutSelf(int uid) {
		List<FullCalendar> flist = new ArrayList<FullCalendar>();
		List<Shedule> slist = shdservice.getSheduleSelf(uid); 
		for (Shedule sd : slist) {
			FullCalendar fc = new FullCalendar();
			fc.setId(sd.getId());
			fc.setTitle(sd.getTital());
				fc.setStart(sd.getStarttime());
				fc.setEnd(sd.getEndtime());
			String color ="";
			if(sd.getPersontype()==0){
				color="#968CFF";
			}else{
				color="#8CFF96";
			}
			if(sd.getDepttype()==1){
				color="#FF9875";
			}
			fc.setColor(color);
			fc.setUid(sd.getUser().getId());
			fc.setRealname(sd.getUser().getRealname());
			flist.add(fc);
		}
		List<Contact> clist = conservice.getContactSelf(uid);
		for (Contact contact : clist) {
			Shedule sd = shdservice.getSheduleById(contact.getShedule().getId());
			FullCalendar fc = new FullCalendar();
			fc.setId(sd.getId());
			fc.setTitle("被预约："+sd.getTital());
				fc.setStart(sd.getStarttime());
				fc.setEnd(sd.getEndtime());
		
			String color ="#FC3BFF";
			
			fc.setColor(color);
			fc.setUid(sd.getUser().getId());
			fc.setRealname(sd.getUser().getRealname());
			flist.add(fc);
		}
		return flist;
	}
	public List<FullCalendar> getFullcAboutDept(int did,int uid) {
		List<FullCalendar> flist = new ArrayList<FullCalendar>();
		List<Shedule> slist = shdservice.getSheduleByDept(did, uid);
		for (Shedule sd : slist) {
			FullCalendar fc = new FullCalendar();
			fc.setId(sd.getId());
			fc.setTitle(sd.getTital());
				fc.setStart(sd.getStarttime());
				fc.setEnd(sd.getEndtime());
			String color ="";
			if(sd.getPersontype()==0){
				color="#968CFF";
			}else{
				color="#8CFF96";
			}
			if(sd.getDepttype()==1){
				color="#FF9875";
			}
			fc.setColor(color);
			fc.setUid(sd.getUser().getId());
			fc.setRealname(sd.getUser().getRealname());
			flist.add(fc);
		}
		return flist;
	}


}
